<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" name="password" />
    <script>
      let input = document.querySelector(`[name="password"]`);
      input.addEventListener('keyup', (e) => {
        const value = e.target.value.trim();
        const regs = [/^[a-zA-Z0-9]{5,10}$/, /[A-Z]/];
        let state = regs.every((v) => v.test(value));
        console.log(state ? '正确！' : '密码必须包含大写字母并在5~10位之间');
      });
    </script>
  </body>
</html>
